﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DSS_XNA.Engine.Script;
using DSS_XNA.Engine.Error;

namespace DSS_XNA.Engine.Script.Functions
{
    public class ScriptFunction_Random
    {
        #region Static Methods

        public static object Action(List<string> args, ScriptManager manager, Game1 engine)
        {
            if (args.Count != 2)
                throw new DSSException("Incorrect number of arguments for Build In Function Random");

            int start = Convert.ToInt32(args[0]);
            int end = Convert.ToInt32(args[1]);

            Random rand = new Random((int)DateTime.Now.Ticks);
            int rnd = rand.Next(start, end);

            // for some reason, rand.Next doesn't make sure that the value is between the passed values...
            if (rnd < start)
                rnd = start;
            if (rnd > end)
                rnd = end;

            return rnd;
        }

        #endregion
    }
}
